package vos.vn.custom.tab;
import vos.vn.R;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class Tab extends TabActivity {
	private TabHost mTabHost;	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.tab);
	    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
	    setupTab(new TextView(this), "Tab 1", TabType.CIRLCE_LEFT);
	    setupTab(new TextView(this), "Tab 2", TabType.NORMAL);
	    setupTab(new TextView(this), "Tab 3", TabType.CIRCLE_RIGTH);
	}
	
	private void setupTab(final View view, final String tag,final TabType type) {
	    View tabview = null;
	    Context context = mTabHost.getContext();
	    TextView tv = null;
	    Intent intent = new Intent().setClass(this, TabContent.class);
	    
	    switch(type) {
	    case CIRCLE_RIGTH:
	    	tabview = LayoutInflater.from(context).inflate(R.layout.tab_right_circle_bg, null);
	    	tv = (TextView) tabview.findViewById(R.id.tabsText);
			tv.setText(tag);
	    	break;
	    case NORMAL:
	    	tabview = LayoutInflater.from(context).inflate(R.layout.tab_bg, null);
	    	tv = (TextView) tabview.findViewById(R.id.tabsText);
			tv.setText(tag);
	    	break;
	    case CIRLCE_LEFT:
	    	tabview = LayoutInflater.from(context).inflate(R.layout.tab_left_circle_bg, null);
	    	tv = (TextView) tabview.findViewById(R.id.tabsText);
			tv.setText(tag);
	    	break;
	    default:
	    		break;
	    }
	    
	    TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(intent);
	    mTabHost.addTab(setContent);
	}
}
